package top.didi.study.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.didi.study.base.PageBean;
import top.didi.study.base.R;
import top.didi.study.entity.TbBillBoard;
import top.didi.study.service.TbBillBoardService;
import top.didi.study.vo.PageVO;

@RestController
@RequestMapping("/tbBillBoard")
@RequiredArgsConstructor
public class TbBillBoardController {
    public final TbBillBoardService tbBillBoardService;

    @PostMapping("")
    public R<String> insert(@RequestBody TbBillBoard tbBillBoard) {
        return tbBillBoardService.insert(tbBillBoard);
    }

    @PutMapping("")
    public R<String> update(@RequestBody TbBillBoard tbBillBoard) {
        return tbBillBoardService.update(tbBillBoard);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbBillBoardService.delete(id);
    }

    @GetMapping("/{id}")
    public R<TbBillBoard> queryById(@PathVariable("id") Integer id) {
        return tbBillBoardService.queryById(id);
    }

    @GetMapping("/{pn}/{ps}")
    public R<PageVO<TbBillBoard>> queryPage(@PathVariable("pn") Long pageNumber, @PathVariable("ps") Long pageSize, TbBillBoard tbBillBoard) {
        return tbBillBoardService.queryPage(PageBean.instance(pageNumber,pageSize),tbBillBoard);
    }
}
